﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace KingSite.Shop.Admin.Controllers
{
    public class ErrorController : Controller {
        public ActionResult HttpError() {
            Exception ex = null;

            try {
                ex = (Exception)HttpContext.Application[Request.UserHostAddress.ToString()];
            }
            catch {
            }

            if (ex != null) {
                ViewData["Description"] = HttpContext.Application["LastErrorMsg"];
            }
            else {
                ViewData["Description"] = "An error occurred.";
            }
            ViewData["Description"] = HttpContext.Application["LastErrorMsg"];

            ViewData["Title"] = "Oops. We're sorry. An error occurred and we're on the case.";
             
            
            return View();
        }

        public ActionResult Http404() {
            ViewData["Title"] = "The page you requested was not found";

            return View();
        }

        // (optional) Redirect to home when /Error is navigated to directly
        public ActionResult Index() {
            return RedirectToAction("Index", "Home");
        }
    }
    
}
